package sample.provider.dml;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.net.Uri;

/**
 * @author YUN
 */
public class SQLInsertBuilder extends SQLBuilder {
	ContentValues mValues = new ContentValues();
	public SQLInsertBuilder(Uri uri) {
		super(uri);
	}
	public void clear() {
		mValues.clear();
	}
	public void addContentValue(String key, Boolean value) {
		mValues.put(key, value);
	}
	public void addContentValue(String key, Byte value) {
		mValues.put(key, value);
	}
	public void addContentValue(String key, byte[] value) {
		mValues.put(key, value);
	}
	public void addContentValue(String key, Double value) {
		mValues.put(key, value);
	}
	public void addContentValue(String key, Float value) {
		mValues.put(key, value);
	}
	public void addContentValue(String key, Integer value) {
		mValues.put(key, value);
	}
	public void addContentValue(String key, Long value) {
		mValues.put(key, value);
	}
	public void addContentValue(String key, Short value) {
		mValues.put(key, value);
	}
	public void addContentValue(String key, String value) {
		mValues.put(key, value);
	}
	/**
	 * <pre>
	 * ...
	 * SQLInsertBuilder sql = new SQLInsertBuilder(uri);
	 * sql.addContentValue("name", "abcd");
	 * Uri newUri = sql.insert(getContentResolver());
	 * ...
	 * </pre>
	 * 
	 * @param contentResolver
	 * @return Uri of the inserted row
	 */
	public Uri insert(ContentResolver contentResolver) {
		return contentResolver.insert(mUri, mValues);
	}
}
